import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from "../views/Index.vue"



Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Index,
    children:[
      {
        path:'/',
        redirect:'/home'
      },
      {
      path:"/home",
      name:'Home',
      component:()=>import("../views/Home.vue")
    },{
      path:"/sort",
      name:'Sort',
      component:()=>import("../views/Sort.vue")
    },{
      path:"/shoppingcart",
      name:'ShoppingCart',
      component:()=>import("../views/ShoppingCart.vue")
    },{
      path:"/me",
      name:'Me',
      component:()=>import("../views/Me.vue")
    }]
  },
  {
    path:'/address',
    name:'Address',
    component:()=>import("../views/Address.vue")
  },
  {
    path:'/addAddress',
    name:'AddAddress',
    component:()=>import("../views/AddAddress.vue")
  },
  {
    path:'/addressSelect',
    name:'AddressSelect',
    component:()=>import("../views/AddressSelect.vue")
  },
  {
    path:'/login',
    name: 'Login',
    component:()=>import("../views/Login.vue")
  },
 
]

const router = new VueRouter({

  routes

})
// router.beforeEach((to,from,next)=>{
//    if(to.name==='Login'){
//      next()
//    }else{
//      next({name:'Login'})
//    }
// })
export default router
